package com.cndw.kungfu.model.operation.domain;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.cndw.kungfu.config.ConstantsConfig;
import com.cndw.kungfu.ext.LogUtil;
import com.cndw.kungfu.ext.StringProcesser;
import com.cndw.kungfu.ext.XmlProcesser;
import com.cndw.kungfu.model.goods.domain.SubPops;

public class DragonAward {
	
	private int id;
	
	private String awardList;
	
	private String num;
	
	private int bind;
	
	private int[] awardArr;
	
	private int[] numArr;
	
	
	private String subPops;
	
	private List<SubPops> subPopsList;
	
	private static final Map<Integer, DragonAward> dragonAwards = new HashMap<Integer, DragonAward>();

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getSubPops() {
		return subPops;
	}

	public void setSubPops(String subPops) {
		this.subPops = subPops;
	}

	public List<SubPops> getSubPopsList() {
		return subPopsList;
	}

	public void setSubPopsList(List<SubPops> subPopsList) {
		this.subPopsList = subPopsList;
	}
	
	public int getBind() {
		return bind;
	}

	public void setBind(int bind) {
		this.bind = bind;
	}

	public String getAwardList() {
		return awardList;
	}

	public void setAwardList(String awardList) {
		this.awardList = awardList;
	}

	public String getNum() {
		return num;
	}

	public void setNum(String num) {
		this.num = num;
	}

	public int[] getAwardArr() {
		return awardArr;
	}

	public void setAwardArr(int[] awardArr) {
		this.awardArr = awardArr;
	}

	public int[] getNumArr() {
		return numArr;
	}

	public void setNumArr(int[] numArr) {
		this.numArr = numArr;
	}
	
	static {
		load();
	}
	
	public static void load() {
		String fileName = ConstantsConfig.getLocaleResource() + "dragonAwards.xml";
		List<DragonAward> tempList = XmlProcesser.processXml(DragonAward.class, fileName);
		for (DragonAward e : tempList) {
			try {
				e.numArr = StringProcesser.toIntArray(e.num);
				e.awardArr = StringProcesser.toIntArray(e.awardList);
			} catch (Exception e2) {
				e2.printStackTrace();
				LogUtil.getMain().error("dragonAwards err " + e.getId());
			}

			if (e.numArr.length != e.awardArr.length) {
				LogUtil.getMain().error("dragonAwards err " + e.getId());
			}
			dragonAwards.put(e.getId(), e);
		}		
	}
	
	public static DragonAward get(int id) {
		return dragonAwards.get(id);
	}

}
